export default {
    set: (key, value) => uni.setStorageSync(key, JSON.stringify(value)),
    get: (key) => {
        const value = uni.getStorageSync(key);
        if (value) {
            if (typeof value === 'string') {
                let returnValue;
                try {
                    returnValue = JSON.parse(value);
                } catch (e) {
                    uni.removeStorageSync(key);
                    returnValue = undefined;
                }
                return returnValue;
            } else {
                return value;
            }
        }
        return null;
    },
    remove: (key) => uni.removeStorageSync(key),
    clear: () => uni.clearStorageSync(),
};
